home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 8 / IOPROG_8.ISO / soft / sdkplnet / mac / plgsk401.sit / PluginSDK 4.01a / Examples / CharFlipper / Source / WinFlipView.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-09  |  3.1 KB  |  138 lines

  1. // WinFlipView.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5.  
  6. #include "WinFlipView.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. #define EVENT_TIMEPASSED    10
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CWinFlipView
  18.  
  19. CWinFlipView::CWinFlipView( CCharFlipper* inController )
  20. :    CFlipView( inController ),
  21.     mWindow( NULL ),
  22.     mTimer( 0 )
  23. {
  24.  
  25. }
  26.  
  27. CWinFlipView::~CWinFlipView()
  28. {
  29. }
  30.  
  31.  
  32. BEGIN_MESSAGE_MAP(CWinFlipView, CWnd)
  33.     //{{AFX_MSG_MAP(CWinFlipView)
  34.     ON_WM_LBUTTONDOWN()
  35.     ON_WM_PAINT()
  36.     ON_WM_TIMER()
  37.     //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CWinFlipView message handlers
  42.  
  43. void CWinFlipView::OnLButtonDown(UINT nFlags, CPoint point) 
  44. {
  45.     // TODO: Add your message handler code here and/or call default
  46.     GetFlipper()->HandleMouseClick();
  47.  
  48.     CWnd::OnLButtonDown(nFlags, point);
  49. }
  50.  
  51.  
  52. void CWinFlipView::OnPaint() 
  53. {
  54.     CPaintDC dc(this); // device context for painting
  55.  
  56.     // TODO: Add your message handler code here
  57.     CString    outText;
  58.     CFont outFont;
  59.  
  60.     outFont.CreateFont( mWindow->height,    // height
  61.                         mWindow->width/2,    // width
  62.                         0,                // escapement
  63.                         0,                // orientation
  64.                         FW_BOLD,        // weight
  65.                         FALSE,            // italics
  66.                         FALSE,            // underline
  67.                         FALSE,            // strikeout
  68.                         ANSI_CHARSET,    // character set
  69.                         OUT_DEVICE_PRECIS,            // outprecision
  70.                         CLIP_DEFAULT_PRECIS,        // clipprecision
  71.                         DEFAULT_QUALITY,            // quality
  72.                         DEFAULT_PITCH | FF_MODERN,    // pitchandfamily
  73.                         NULL );                // facename
  74.  
  75.     CFont* oldFont = (CFont*) dc.SelectObject( & outFont );
  76.  
  77.     outText.Format("%c", mCurrentChar );
  78.     dc.TextOut( 0, 0, outText );
  79.     // Do not call CWnd::OnPaint() for painting messages
  80. }
  81.  
  82. //---------------------------------------------------------
  83. // CWinFlipView::GetWindow
  84. //---------------------------------------------------------
  85. NPWindow*
  86. CWinFlipView::GetWindow()
  87. {
  88.     return mWindow;
  89. }
  90.  
  91. //---------------------------------------------------------
  92. // CWinFlipView::SetWindow
  93. //---------------------------------------------------------
  94. NPError
  95. CWinFlipView::SetWindow( NPWindow* inWindow )
  96. {
  97.     if( mWindow != NULL ) {
  98.         if( mTimer ) {
  99.             KillTimer( mTimer );
  100.             mTimer = 0;
  101.         }
  102.         UnsubclassWindow();
  103.         mWindow = NULL;
  104.     }
  105.     if( inWindow != NULL ) {
  106.         if( inWindow->window != NULL ) {
  107.             SubclassWindow( (HWND) (inWindow->window) );
  108.             mWindow = inWindow;
  109.             Paint();
  110.             mTimer = SetTimer( EVENT_TIMEPASSED, 10, NULL );
  111.  
  112.         }
  113.     }
  114.     return NPERR_NO_ERROR;
  115. }
  116.  
  117. //---------------------------------------------------------
  118. // CWinFlipView::Paint
  119. //---------------------------------------------------------
  120. void
  121. CWinFlipView::Paint()
  122. {
  123.     if( mWindow != NULL ) {
  124.         Invalidate();
  125.         UpdateWindow();
  126.     }
  127. }
  128.  
  129.  
  130. void CWinFlipView::OnTimer(UINT nIDEvent) 
  131. {
  132.     // TODO: Add your message handler code here and/or call default
  133.     if( nIDEvent == EVENT_TIMEPASSED ) {
  134.         GetFlipper()->HandleTimePassed();
  135.     }
  136.     CWnd::OnTimer(nIDEvent);
  137. }
  138.